<?php

/**
 * @author jrodriguez
 * @copyright 2013
 */

require_once 'MysqlConnection.php';
require_once 'MysqlResult.php';
require_once 'Repositories/BaseRepository.php';
require_once 'Repositories/RSSSourceRepository.php';
require_once '../Gazzetta.Entities/RSSSource.php';
try {
    $repository = new RSSSourceRepository();
    
    //$result = $conn->getResultSet('SELECT * FROM rssSource');
   // $result = $repository->getById(2);
    $entity = new RSSSource();
    $entity->setLink('www.sadsa.com');
    $entity->setIdCategory(2);
    
    $repository->add($entity);
   
    $resultAll = $repository->all();
    
    foreach($resultAll as $result){
      echo $result->getId();
      echo '<br />';
      echo $result->getLink();
      echo '<br />';
      echo $result->getTitle();
      echo '<br />';
      echo $result->getDescription();
      echo '<br />';
      }
   // $rsssource = new RSSSource();
    
    //$repository->add($rsssource);
    
    //foreach ($result as $row) {
//        foreach ($row as $field => $value) 
//        {
//            
//            echo "$field: $value<br />";
//        }
//        echo '<br />';
//    }
} catch (RuntimeException $e) {
    echo 'This is a RuntimeException: ' . $e->getMessage();
} catch (Exception $e) {
    echo 'This is an ordinary Exception: ' . $e->getMessage();
}
?>